export function to<T>(promise: Promise<T> | undefined): Promise<Error | null> {
  if (promise === undefined) {
    return Promise.reject(new Error('ref object is undefined'))
  }
  return promise.then(() => null).catch((error: Error) => error)
}

export default to
